/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Ocso;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Alex
 */
public class MostrarProd {

public String ver(String cod) {
    String dat= "";
    String dat2= "";
     String salida="";
   //int aInt=0;
        try {
            Connection c = DriverManager.getConnection("jdbc:mysql://localhost/Ventas", "root", "");
            Statement sql = c.createStatement();


            ResultSet datos = sql.executeQuery("select * from productos where codigo='" + cod + "'"  );
            while (datos.next()) {

                dat= datos.getString("producto");
                 dat2= datos.getString("precio");

                 System.out.println("producto"+dat);
                // aInt = Integer.parseInt(aString);

  salida = "producto" +"  "+ dat +"     "+ "precio  " + dat2+"  "+"pesos";

            }
        } catch (SQLException ex) {
            Logger.getLogger(MostrarProd.class.getName()).log(Level.SEVERE, null, ex);
        }
return salida;
    }

public String verPrecio(String cod) {

    String dat2= "";

   //int aInt=0;
        try {
            Connection c = DriverManager.getConnection("jdbc:mysql://localhost/Ventas", "root", "");
            Statement sql = c.createStatement();


            ResultSet datos = sql.executeQuery("select * from productos where codigo='" + cod + "'"  );
            while (datos.next()) {


                 dat2= datos.getString("precio");



            }
        } catch (SQLException ex) {
            Logger.getLogger(MostrarProd.class.getName()).log(Level.SEVERE, null, ex);
        }
return dat2;
    }


}






//public String password(String pass) {
//        String contra = "";
//        String contra1 = "";
//        try {
//            Connection c = DriverManager.getConnection("jdbc:mysql://localhost/chat", "root", "");
//            Statement sql = c.createStatement();
//
//            ResultSet datos = sql.executeQuery("select * from usuario2 where contrasena='" + pass + "'");
//
//            while (datos.next()) {
//
//
//
//                contra = datos.getString("contrasena");
//
//                System.out.println("contrasena" + contra);
//
//
//            }
//            if (pass.compareTo(contra) == 0) {
//                    System.out.println("Contraseña correcta" + contra);
//                    contra1 = pass;
//                }
//
//            else{
//                JOptionPane.showMessageDialog(null, "Contraseña incorrecta ");
//                contra1=null;
//            }
//
//        } catch (SQLException ex) {
//            Logger.getLogger(ConexionMySql.class.getName()).log(Level.SEVERE, null, ex);
//        }
//
//
//        return contra1;
//
//
//    }